// 异步模式

// 消息队列： Queue
// 事件循环： event loop
// Call stack
// Web APIs

console.log('global begin')
setTimeout(function time1(){
    console.log('time1 invoke')
}, 1800)

setTimeout(function time2(){
    console.log('time2 invoke')
    setTimeout(function inner(){
        console.log('inner invoke')
    },1000)
},1000)

console.log('global end')

/*
---------- console start ----------
    global begin
    global end
    time2 invoke
    time1 invoke
    inner invoke
---------- console end ----------


----------  Call stack start ----------
    console.log('global begin')
    1 - setTimeout(time1)
    2 - setTimeout(time2)
    console.log('global end')
    3 - timer2()
    console.log('time2 invoke')
    4 - setTimeout(inner)
    console.log('time1 invoke')
    console.log('inner invoke')
----------  Call stack end ----------


----------  Web APIs start ----------
    1 - 1800ms timer1
    2 - 1000ms timer2
    3 - 1000ms inner
----------  Web APIs end ----------


----------  Queue/event loop start ----------
    1 - timer2()
    2 - timer1()
    3 - inner()
----------  Queue/event loop end ----------
*/












